//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class demo_2610 {
    public demo_2610() {
    }

    public static void main(String[] args) {
        int[] nums = new int[]{1, 3, 4, 1, 2, 3, 1};

        for(List<Integer> list : findMatrix(nums)) {
            System.out.println(list.toString());
        }

    }

    public static List<List<Integer>> findMatrix(int[] nums) {
        Arrays.sort(nums);
        List<List<Integer>> res = new ArrayList();
        int j = 0;
        List<Integer> one = new ArrayList();
        one.add(nums[0]);
        res.add(one);

        for(int i = 1; i < nums.length; ++i) {
            if (nums[i - 1] == nums[i]) {
                ++j;
            } else {
                j = 0;
            }

            if (res.size() == j) {
                List<Integer> list = new ArrayList();
                list.add(nums[i]);
                res.add(list);
            } else {
                List<Integer> list = (List)res.get(j);
                list.add(nums[i]);
                res.set(j, list);
            }
        }

        return res;
    }
}
